package test;

public class GCDAndLCM {
    public static int greatestCommonDivisor(int num1, int num2) {
        // 使用欧几里得算法计算最大公约数
        while (num2!= 0) {
            int temp = num2;
            num2 = num1 % num2;
            num1 = temp;
        }
        return num1;
    }
    public static int leastCommonMultiple(int num1, int num2) {
        // 根据最小公倍数等于两数之积除以最大公约数的性质计算最小公倍数
        return num1 * num2 / greatestCommonDivisor(num1, num2);
    }
    public static void main(String[] args) {
        int num1 = 15;
        int num2 = 25;
        int gcd = greatestCommonDivisor(num1, num2);
        int lcm = leastCommonMultiple(num1, num2);
        System.out.println("最大公约数：" + gcd);
        System.out.println("最小公倍数：" + lcm);
    }
}